package com.example.demo.threadDemo.aCreateThreadName;

/**
 * @Description Demo01
 * @Author songchuanlong
 * @Date 2025-04-14
 */


/**
 * Thread m = Thread.currentThread();在哪里，m就执行哪条线程
 */
public class Demo01 {
    public static void main(String[] args) {
        Thread myThread01 = new MyThread01();
        //通过setname设置名字
        myThread01.setName("小美的线程");
        myThread01.start();

        Thread myThread02 = new MyThread01();
        //通过setname设置名字
        myThread02.setName("小帅的线程");
        myThread02.start();

        //哪个线程执行它就会得到哪个线程的对象
        Thread m = Thread.currentThread();
        //通过setname设置名字
        m.setName("主要的线程");
        for (int i = 1; i <=3; i++) {
            System.out.println(m.getName()+":"+i);
        }
    }
}
